#ifndef SERIALIZATOR_H
#define SERIALIZATOR_H

#include <QObject>
#include <QMetaType>

class ObjectString : public QString
{
public:
    ObjectString() : QString()
    {
    }
    ObjectString(const QString& str) : QString(str)
    {
    }
};

Q_DECLARE_METATYPE(ObjectString)

namespace Core
{

class ISerializator
{
public:
    virtual void beginObject() = 0;
    virtual void endObject() = 0;

    virtual void writeProperty(const QString& propertyName, const QVariant& propertyValue) = 0;

    virtual void beginList(const QString& propertyName) = 0;
    virtual void writeListItem(const QVariant& item) = 0;
    virtual void endList() = 0;

    virtual void clear() = 0;
    virtual ObjectString result() = 0;
};

class IDeserializator
{
public:
    enum PropertyType { Variant, List, Object };
    virtual void beginObject() = 0;
    virtual void endObject() = 0;

    virtual QString readPropertyName() = 0;
    virtual PropertyType readPropertyType() = 0;
    virtual QVariant readPropertyValue() = 0;

    virtual void beginList() = 0;
    virtual void endList() = 0;

    virtual PropertyType readListItemType() = 0;
    virtual QVariant readListItem() = 0;
};

}

#endif // SERIALIZATOR_H
